package com.kunteng.ynhxksh.controller;

import com.kunteng.ynhxksh.service.KPGKService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Created By ShiYun with IntelliJ IDEA on 2018/4/2 10:28
 *
 * @author: ShiYun
 * @Email: 515867726@qq.com
 * @Date: 2018/4/2
 * To change this template use File | Settings | File Templates.
 */
@Api(tags = "开票管控接口")
@RestController
@RequestMapping("/kpgk")
public class KPGKController {

    Logger logger = LoggerFactory.getLogger(KPGKController.class);

    @Autowired
    private KPGKService kpgkService;

    @ApiOperation(value = "开票内容占比", notes = "返回开票交易商品占比信息")
    @RequestMapping(value = "/findKPZBInfos", method = RequestMethod.GET)
    public JSONArray findKPZBInfos() {
        logger.info("findKPZBInfos");
        List<Map> rate = kpgkService.mcRate();
        JSONArray jsonArray = JSONArray.fromObject(rate);
        return jsonArray;
    }


    @ApiOperation(value = "开票延迟时间", notes = "返回开票延迟时间分布")
    @RequestMapping(value = "/findKPYCInfos", method = RequestMethod.GET)
    public JSONObject findKPYCInfos() {
        logger.info("findKPYCInfos");
        return kpgkService.queryKPYC();
    }

    @ApiOperation(value = "实时开票记录", notes = "返回实时开票记录信息")
    @RequestMapping(value = "/findKPInfos", method = RequestMethod.GET)
    public JSONArray findKPInfos() {
        logger.info("findKPInfos");
        List<Map> timeInfoKP = kpgkService.timeInfoKP();
        JSONArray jsonArray = JSONArray.fromObject(timeInfoKP);
        return jsonArray;
    }

//    @ApiOperation(value = "开票管控", notes = "内容占比")
//    @RequestMapping(value = "/kpgk", method = RequestMethod.GET)
//    public String kpgk() {
//        List<Map> rate = kpgkService.mcRate();
//        for (Map map : rate) {
//            out1(map);
//        }
//        List<Map> timeInfoKP = kpgkService.timeInfoKP();
//        for (Map map : timeInfoKP) {
//            out(map);
//        }
//
//        return "hello";
//    }
//
//    public static void out(Map map) {
//        System.out.println("je=" + String.valueOf(map.get("je")) + " rq=" + String.valueOf(map.get("rq"))
//                + " mc=" + String.valueOf(map.get("mc")) + " hy=" + String.valueOf(map.get("hy"))
//                + " name=" + String.valueOf(map.get("name")));
//    }
//
//    public static void out1(Map map) {
//        System.out.println("je=" + String.valueOf(map.get("je")) + " mc=" + String.valueOf(map.get("mc"))
//                + " rate=" + String.valueOf(map.get("rate")));
//    }
}
